<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Module: ActiveRecord::ConnectionAdapters::SchemaStatements</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Module</strong></td>
          <td class="class-name-in-header">ActiveRecord::ConnectionAdapters::SchemaStatements</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../../files/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements_rb.html">
                vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
                </a>
        <br />
            </td>
        </tr>

        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">



   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M001153">add_column</a>&nbsp;&nbsp;
      <a href="#M001158">add_index</a>&nbsp;&nbsp;
      <a href="#M001163">add_order_by_for_association_limiting!</a>&nbsp;&nbsp;
      <a href="#M001155">change_column</a>&nbsp;&nbsp;
      <a href="#M001156">change_column_default</a>&nbsp;&nbsp;
      <a href="#M001149">columns</a>&nbsp;&nbsp;
      <a href="#M001150">create_table</a>&nbsp;&nbsp;
      <a href="#M001162">distinct</a>&nbsp;&nbsp;
      <a href="#M001152">drop_table</a>&nbsp;&nbsp;
      <a href="#M001161">initialize_schema_information</a>&nbsp;&nbsp;
      <a href="#M001146">native_database_types</a>&nbsp;&nbsp;
      <a href="#M001164">options_include_default?</a>&nbsp;&nbsp;
      <a href="#M001154">remove_column</a>&nbsp;&nbsp;
      <a href="#M001159">remove_index</a>&nbsp;&nbsp;
      <a href="#M001157">rename_column</a>&nbsp;&nbsp;
      <a href="#M001151">rename_table</a>&nbsp;&nbsp;
      <a href="#M001160">structure_dump</a>&nbsp;&nbsp;
      <a href="#M001148">table_alias_for</a>&nbsp;&nbsp;
      <a href="#M001147">table_alias_length</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">





      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M001153" class="method-detail">
        <a name="M001153"></a>

        <div class="method-heading">
          <a href="#M001153" class="method-signature">
          <span class="method-name">add_column</span><span class="method-args">(table_name, column_name, type, options = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Adds a new column to the named table. See <a
href="TableDefinition.html#M001222">TableDefinition#column</a> for details
of the options you can use.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001153-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001153-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb, line 121</span>
121:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_column</span>(<span class="ruby-identifier">table_name</span>, <span class="ruby-identifier">column_name</span>, <span class="ruby-identifier">type</span>, <span class="ruby-identifier">options</span> = {})
122:         <span class="ruby-identifier">add_column_sql</span> = <span class="ruby-node">&quot;ALTER TABLE #{quote_table_name(table_name)} ADD #{quote_column_name(column_name)} #{type_to_sql(type, options[:limit], options[:precision], options[:scale])}&quot;</span>
123:         <span class="ruby-identifier">add_column_options!</span>(<span class="ruby-identifier">add_column_sql</span>, <span class="ruby-identifier">options</span>)
124:         <span class="ruby-identifier">execute</span>(<span class="ruby-identifier">add_column_sql</span>)
125:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001158" class="method-detail">
        <a name="M001158"></a>

        <div class="method-heading">
          <a href="#M001158" class="method-signature">
          <span class="method-name">add_index</span><span class="method-args">(table_name, column_name, options = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Adds a new index to the table. <tt>column_name</tt> can be a single Symbol,
or an Array of Symbols.
</p>
<p>
The index will be named after the table and the first column name, unless
you pass +:name+ as an option.
</p>
<p>
When creating an index on multiple <a
href="SchemaStatements.html#M001149">columns</a>, the first column is used
as a name for the index. For example, when you specify an index on two <a
href="SchemaStatements.html#M001149">columns</a> [+:first+, +:last+], the
DBMS creates an index for both <a
href="SchemaStatements.html#M001149">columns</a> as well as an index for
the first column +:first+. Using just the first name for this index makes
sense, because you will never have to create a singular index with this
name.
</p>
<h5>Examples</h5>
<h6>Creating a simple index</h6>
<pre>
 add_index(:suppliers, :name)
</pre>
<p>
generates
</p>
<pre>
 CREATE INDEX suppliers_name_index ON suppliers(name)
</pre>
<h6>Creating a unique index</h6>
<pre>
 add_index(:accounts, [:branch_id, :party_id], :unique =&gt; true)
</pre>
<p>
generates
</p>
<pre>
 CREATE UNIQUE INDEX accounts_branch_id_party_id_index ON accounts(branch_id, party_id)
</pre>
<h6>Creating a named index</h6>
<pre>
 add_index(:accounts, [:branch_id, :party_id], :unique =&gt; true, :name =&gt; 'by_branch_party')
</pre>
<p>
generates
</p>
<pre>
 CREATE UNIQUE INDEX by_branch_party ON accounts(branch_id, party_id)
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001158-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001158-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb, line 186</span>
186:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_index</span>(<span class="ruby-identifier">table_name</span>, <span class="ruby-identifier">column_name</span>, <span class="ruby-identifier">options</span> = {})
187:         <span class="ruby-identifier">column_names</span> = <span class="ruby-constant">Array</span>(<span class="ruby-identifier">column_name</span>)
188:         <span class="ruby-identifier">index_name</span>   = <span class="ruby-identifier">index_name</span>(<span class="ruby-identifier">table_name</span>, <span class="ruby-identifier">:column</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">column_names</span>)
189: 
190:         <span class="ruby-keyword kw">if</span> <span class="ruby-constant">Hash</span> <span class="ruby-operator">===</span> <span class="ruby-identifier">options</span> <span class="ruby-comment cmt"># legacy support, since this param was a string</span>
191:           <span class="ruby-identifier">index_type</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:unique</span>] <span class="ruby-operator">?</span> <span class="ruby-value str">&quot;UNIQUE&quot;</span> <span class="ruby-operator">:</span> <span class="ruby-value str">&quot;&quot;</span>
192:           <span class="ruby-identifier">index_name</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:name</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">index_name</span>
193:         <span class="ruby-keyword kw">else</span>
194:           <span class="ruby-identifier">index_type</span> = <span class="ruby-identifier">options</span>
195:         <span class="ruby-keyword kw">end</span>
196:         <span class="ruby-identifier">quoted_column_names</span> = <span class="ruby-identifier">column_names</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span> <span class="ruby-identifier">quote_column_name</span>(<span class="ruby-identifier">e</span>) }.<span class="ruby-identifier">join</span>(<span class="ruby-value str">&quot;, &quot;</span>)
197:         <span class="ruby-identifier">execute</span> <span class="ruby-node">&quot;CREATE #{index_type} INDEX #{quote_column_name(index_name)} ON #{quote_table_name(table_name)} (#{quoted_column_names})&quot;</span>
198:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001163" class="method-detail">
        <a name="M001163"></a>

        <div class="method-heading">
          <a href="#M001163" class="method-signature">
          <span class="method-name">add_order_by_for_association_limiting!</span><span class="method-args">(sql, options)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
ORDER BY clause for the passed order option. PostgreSQL overrides this due
to its stricter standards compliance.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001163-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001163-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb, line 296</span>
296:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_order_by_for_association_limiting!</span>(<span class="ruby-identifier">sql</span>, <span class="ruby-identifier">options</span>)
297:         <span class="ruby-identifier">sql</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot; ORDER BY #{options[:order]}&quot;</span>
298:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001155" class="method-detail">
        <a name="M001155"></a>

        <div class="method-heading">
          <a href="#M001155" class="method-signature">
          <span class="method-name">change_column</span><span class="method-args">(table_name, column_name, type, options = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Changes the column&#8216;s definition according to the new options. See <a
href="TableDefinition.html#M001222">TableDefinition#column</a> for details
of the options you can use.
</p>
<h5>Examples</h5>
<pre>
 change_column(:suppliers, :name, :string, :limit =&gt; 80)
 change_column(:accounts, :description, :text)
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001155-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001155-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb, line 139</span>
139:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">change_column</span>(<span class="ruby-identifier">table_name</span>, <span class="ruby-identifier">column_name</span>, <span class="ruby-identifier">type</span>, <span class="ruby-identifier">options</span> = {})
140:         <span class="ruby-identifier">raise</span> <span class="ruby-constant">NotImplementedError</span>, <span class="ruby-value str">&quot;change_column is not implemented&quot;</span>
141:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001156" class="method-detail">
        <a name="M001156"></a>

        <div class="method-heading">
          <a href="#M001156" class="method-signature">
          <span class="method-name">change_column_default</span><span class="method-args">(table_name, column_name, default)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Sets a new default value for a column. If you want to set the default value
to <tt>NULL</tt>, you are out of luck. You need to <a
href="DatabaseStatements.html#M001178">DatabaseStatements#execute</a> the
appropriate SQL statement yourself.
</p>
<h5>Examples</h5>
<pre>
 change_column_default(:suppliers, :qualification, 'new')
 change_column_default(:accounts, :authorized, 1)
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001156-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001156-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb, line 149</span>
149:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">change_column_default</span>(<span class="ruby-identifier">table_name</span>, <span class="ruby-identifier">column_name</span>, <span class="ruby-identifier">default</span>)
150:         <span class="ruby-identifier">raise</span> <span class="ruby-constant">NotImplementedError</span>, <span class="ruby-value str">&quot;change_column_default is not implemented&quot;</span>
151:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001149" class="method-detail">
        <a name="M001149"></a>

        <div class="method-heading">
          <a href="#M001149" class="method-signature">
          <span class="method-name">columns</span><span class="method-args">(table_name, name = nil)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns an array of <a href="Column.html">Column</a> objects for the table
specified by <tt>table_name</tt>. See the concrete implementation for
details on the expected parameter values.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001149-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001149-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb, line 28</span>
28:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">columns</span>(<span class="ruby-identifier">table_name</span>, <span class="ruby-identifier">name</span> = <span class="ruby-keyword kw">nil</span>) <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001150" class="method-detail">
        <a name="M001150"></a>

        <div class="method-heading">
          <a href="#M001150" class="method-signature">
          <span class="method-name">create_table</span><span class="method-args">(table_name, options = {}) {|table_definition| ...}</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Creates a new table There are two ways to work with <a
href="SchemaStatements.html#M001150">create_table</a>. You can use the
block form or the regular form, like this:
</p>
<h3>Block form</h3>
<pre>
 # create_table() yields a TableDefinition instance
 create_table(:suppliers) do |t|
   t.column :name, :string, :limit =&gt; 60
   # Other fields here
 end
</pre>
<h3>Regular form</h3>
<pre>
 create_table(:suppliers)
 add_column(:suppliers, :name, :string, {:limit =&gt; 60})
</pre>
<p>
The <tt>options</tt> hash can include the following keys:
</p>
<dl>
<dt><tt>:id</tt></dt><dd>Whether to automatically add a primary key column. Defaults to true. Join
tables for has_and_belongs_to_many should set :id =&gt; false.

</dd>
<dt><tt>:primary_key</tt></dt><dd>The name of the primary key, if one is to be added automatically. Defaults
to <tt>id</tt>.

</dd>
<dt><tt>:options</tt></dt><dd>Any extra options you want appended to the table definition.

</dd>
<dt><tt>:temporary</tt></dt><dd>Make a temporary table.

</dd>
<dt><tt>:force</tt></dt><dd>Set to true to drop the table before creating it. Defaults to false.

</dd>
</dl>
<h5>Examples</h5>
<h6>Add a backend specific option to the generated SQL (MySQL)</h6>
<pre>
 create_table(:suppliers, :options =&gt; 'ENGINE=InnoDB DEFAULT CHARSET=utf8')
</pre>
<p>
generates:
</p>
<pre>
 CREATE TABLE suppliers (
   id int(11) DEFAULT NULL auto_increment PRIMARY KEY
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
</pre>
<h6>Rename the primary key column</h6>
<pre>
 create_table(:objects, :primary_key =&gt; 'guid') do |t|
   t.column :name, :string, :limit =&gt; 80
 end
</pre>
<p>
generates:
</p>
<pre>
 CREATE TABLE objects (
   guid int(11) DEFAULT NULL auto_increment PRIMARY KEY,
   name varchar(80)
 )
</pre>
<h6>Do not add a primary key column</h6>
<pre>
 create_table(:categories_suppliers, :id =&gt; false) do |t|
   t.column :category_id, :integer
   t.column :supplier_id, :integer
 end
</pre>
<p>
generates:
</p>
<pre>
 CREATE TABLE categories_suppliers (
   category_id int,
   supplier_id int
 )
</pre>
<p>
See also <a href="TableDefinition.html#M001222">TableDefinition#column</a>
for details on how to create <a
href="SchemaStatements.html#M001149">columns</a>.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001150-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001150-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb, line 90</span>
 90:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">create_table</span>(<span class="ruby-identifier">table_name</span>, <span class="ruby-identifier">options</span> = {})
 91:         <span class="ruby-identifier">table_definition</span> = <span class="ruby-constant">TableDefinition</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword kw">self</span>)
 92:         <span class="ruby-identifier">table_definition</span>.<span class="ruby-identifier">primary_key</span>(<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:primary_key</span>] <span class="ruby-operator">||</span> <span class="ruby-value str">&quot;id&quot;</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:id</span>] <span class="ruby-operator">==</span> <span class="ruby-keyword kw">false</span>
 93: 
 94:         <span class="ruby-keyword kw">yield</span> <span class="ruby-identifier">table_definition</span>
 95: 
 96:         <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:force</span>]
 97:           <span class="ruby-identifier">drop_table</span>(<span class="ruby-identifier">table_name</span>, <span class="ruby-identifier">options</span>) <span class="ruby-keyword kw">rescue</span> <span class="ruby-keyword kw">nil</span>
 98:         <span class="ruby-keyword kw">end</span>
 99: 
100:         <span class="ruby-identifier">create_sql</span> = <span class="ruby-node">&quot;CREATE#{' TEMPORARY' if options[:temporary]} TABLE &quot;</span>
101:         <span class="ruby-identifier">create_sql</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;#{quote_table_name(table_name)} (&quot;</span>
102:         <span class="ruby-identifier">create_sql</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">table_definition</span>.<span class="ruby-identifier">to_sql</span>
103:         <span class="ruby-identifier">create_sql</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;) #{options[:options]}&quot;</span>
104:         <span class="ruby-identifier">execute</span> <span class="ruby-identifier">create_sql</span>
105:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001162" class="method-detail">
        <a name="M001162"></a>

        <div class="method-heading">
          <a href="#M001162" class="method-signature">
          <span class="method-name">distinct</span><span class="method-args">(columns, order_by)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
SELECT DISTINCT clause for a given set of <a
href="SchemaStatements.html#M001149">columns</a> and a given ORDER BY
clause. Both PostgreSQL and Oracle overrides this for custom DISTINCT
syntax.
</p>
<pre>
  distinct(&quot;posts.id&quot;, &quot;posts.created_at desc&quot;)
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001162-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001162-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb, line 290</span>
290:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">distinct</span>(<span class="ruby-identifier">columns</span>, <span class="ruby-identifier">order_by</span>)
291:         <span class="ruby-node">&quot;DISTINCT #{columns}&quot;</span>
292:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001152" class="method-detail">
        <a name="M001152"></a>

        <div class="method-heading">
          <a href="#M001152" class="method-signature">
          <span class="method-name">drop_table</span><span class="method-args">(table_name, options = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Drops a table from the database.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001152-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001152-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb, line 115</span>
115:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">drop_table</span>(<span class="ruby-identifier">table_name</span>, <span class="ruby-identifier">options</span> = {})
116:         <span class="ruby-identifier">execute</span> <span class="ruby-node">&quot;DROP TABLE #{quote_table_name(table_name)}&quot;</span>
117:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001161" class="method-detail">
        <a name="M001161"></a>

        <div class="method-heading">
          <a href="#M001161" class="method-signature">
          <span class="method-name">initialize_schema_information</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Should not be called normally, but this operation is non-destructive. The
migrations module handles this automatically.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001161-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001161-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb, line 235</span>
235:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize_schema_information</span>
236:         <span class="ruby-keyword kw">begin</span>
237:           <span class="ruby-identifier">execute</span> <span class="ruby-node">&quot;CREATE TABLE #{quote_table_name(ActiveRecord::Migrator.schema_info_table_name)} (version #{type_to_sql(:integer)})&quot;</span>
238:           <span class="ruby-identifier">execute</span> <span class="ruby-node">&quot;INSERT INTO #{quote_table_name(ActiveRecord::Migrator.schema_info_table_name)} (version) VALUES(0)&quot;</span>
239:         <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">ActiveRecord</span><span class="ruby-operator">::</span><span class="ruby-constant">StatementInvalid</span>
240:           <span class="ruby-comment cmt"># Schema has been initialized</span>
241:         <span class="ruby-keyword kw">end</span>
242:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001146" class="method-detail">
        <a name="M001146"></a>

        <div class="method-heading">
          <a href="#M001146" class="method-signature">
          <span class="method-name">native_database_types</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a Hash of mappings from the abstract data types to the native
database types. See <a
href="TableDefinition.html#M001222">TableDefinition#column</a> for details
on the recognized abstract data types.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001146-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001146-source">
<pre>
   <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb, line 7</span>
7:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">native_database_types</span>
8:         {}
9:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001154" class="method-detail">
        <a name="M001154"></a>

        <div class="method-heading">
          <a href="#M001154" class="method-signature">
          <span class="method-name">remove_column</span><span class="method-args">(table_name, column_name)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Removes the column from the table definition.
</p>
<h5>Examples</h5>
<pre>
 remove_column(:suppliers, :qualification)
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001154-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001154-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb, line 130</span>
130:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">remove_column</span>(<span class="ruby-identifier">table_name</span>, <span class="ruby-identifier">column_name</span>)
131:         <span class="ruby-identifier">execute</span> <span class="ruby-node">&quot;ALTER TABLE #{quote_table_name(table_name)} DROP #{quote_column_name(column_name)}&quot;</span>
132:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001159" class="method-detail">
        <a name="M001159"></a>

        <div class="method-heading">
          <a href="#M001159" class="method-signature">
          <span class="method-name">remove_index</span><span class="method-args">(table_name, options = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Remove the given index from the table.
</p>
<p>
Remove the suppliers_name_index in the suppliers table.
</p>
<pre>
  remove_index :suppliers, :name
</pre>
<p>
Remove the index named accounts_branch_id_index in the accounts table.
</p>
<pre>
  remove_index :accounts, :column =&gt; :branch_id
</pre>
<p>
Remove the index named accounts_branch_id_party_id_index in the accounts
table.
</p>
<pre>
  remove_index :accounts, :column =&gt; [:branch_id, :party_id]
</pre>
<p>
Remove the index named by_branch_party in the accounts table.
</p>
<pre>
  remove_index :accounts, :name =&gt; :by_branch_party
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001159-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001159-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb, line 210</span>
210:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">remove_index</span>(<span class="ruby-identifier">table_name</span>, <span class="ruby-identifier">options</span> = {})
211:         <span class="ruby-identifier">execute</span> <span class="ruby-node">&quot;DROP INDEX #{quote_column_name(index_name(table_name, options))} ON #{table_name}&quot;</span>
212:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001157" class="method-detail">
        <a name="M001157"></a>

        <div class="method-heading">
          <a href="#M001157" class="method-signature">
          <span class="method-name">rename_column</span><span class="method-args">(table_name, column_name, new_column_name)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Renames a column.
</p>
<h5>Example</h5>
<pre>
 rename_column(:suppliers, :description, :name)
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001157-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001157-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb, line 156</span>
156:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">rename_column</span>(<span class="ruby-identifier">table_name</span>, <span class="ruby-identifier">column_name</span>, <span class="ruby-identifier">new_column_name</span>)
157:         <span class="ruby-identifier">raise</span> <span class="ruby-constant">NotImplementedError</span>, <span class="ruby-value str">&quot;rename_column is not implemented&quot;</span>
158:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001151" class="method-detail">
        <a name="M001151"></a>

        <div class="method-heading">
          <a href="#M001151" class="method-signature">
          <span class="method-name">rename_table</span><span class="method-args">(table_name, new_name)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Renames a table.
</p>
<h5>Example</h5>
<pre>
 rename_table('octopuses', 'octopi')
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001151-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001151-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb, line 110</span>
110:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">rename_table</span>(<span class="ruby-identifier">table_name</span>, <span class="ruby-identifier">new_name</span>)
111:         <span class="ruby-identifier">raise</span> <span class="ruby-constant">NotImplementedError</span>, <span class="ruby-value str">&quot;rename_table is not implemented&quot;</span>
112:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001160" class="method-detail">
        <a name="M001160"></a>

        <div class="method-heading">
          <a href="#M001160" class="method-signature">
          <span class="method-name">structure_dump</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a string of <tt>CREATE TABLE</tt> SQL statement(s) for recreating
the entire structure of the database.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001160-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001160-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb, line 230</span>
230:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">structure_dump</span>
231:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001148" class="method-detail">
        <a name="M001148"></a>

        <div class="method-heading">
          <a href="#M001148" class="method-signature">
          <span class="method-name">table_alias_for</span><span class="method-args">(table_name)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Truncates a table alias according to the limits of the current adapter.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001148-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001148-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb, line 17</span>
17:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">table_alias_for</span>(<span class="ruby-identifier">table_name</span>)
18:         <span class="ruby-identifier">table_name</span>[<span class="ruby-value">0</span><span class="ruby-operator">..</span><span class="ruby-identifier">table_alias_length</span><span class="ruby-operator">-</span><span class="ruby-value">1</span>].<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/\./</span>, <span class="ruby-value str">'_'</span>)
19:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001147" class="method-detail">
        <a name="M001147"></a>

        <div class="method-heading">
          <a href="#M001147" class="method-signature">
          <span class="method-name">table_alias_length</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
This is the maximum length a table alias can be
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001147-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001147-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb, line 12</span>
12:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">table_alias_length</span>
13:         <span class="ruby-value">255</span>
14:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <h3 class="section-bar">Protected Instance methods</h3>

      <div id="method-M001164" class="method-detail">
        <a name="M001164"></a>

        <div class="method-heading">
          <a href="#M001164" class="method-signature">
          <span class="method-name">options_include_default?</span><span class="method-args">(options)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001164-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001164-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb, line 301</span>
301:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">options_include_default?</span>(<span class="ruby-identifier">options</span>)
302:           <span class="ruby-identifier">options</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">:default</span>) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-operator">!</span>(<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:null</span>] <span class="ruby-operator">==</span> <span class="ruby-keyword kw">false</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:default</span>].<span class="ruby-identifier">nil?</span>)
303:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>